-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix re.split(...)
return type
#5269
Conversation
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This change breaks a lot of code that assumes the list doesn't contain We have some options:
What do you think? |
This can also be implemented more precisely in a type checker plugin that could look at the regex to see if there are optional groups. |
I guess so. I was just startled when mypy assured me that split returns |
There's not a good way to express this in stubs. If you want, you can create a feature request to mypy. |
See #3902 for discussion about |
Another option is to use Type checkers can still optionally special case this based on the regular expression string and provide more precise types when possible. |
Yeah that sounds nice. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
re.split(...)
return type
Example: